package com.ruoyi.project.datacollection.datasource.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.datacollection.datasource.domain.Datasource;
import com.ruoyi.project.datacollection.datasource.service.DatasourceService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author dayang
 * @version 1.0
 * @time 2022/7/28 - 星期四
 */
@RestController
@RequestMapping("/datasource")
public class DataController extends BaseController {

    @Resource
    private DatasourceService datasourceService;


    /**
     * 新增数据源
     */
    @PostMapping("")
    public AjaxResult insertDataSource(@RequestBody Datasource datasource) {
        return datasourceService.insertData(datasource);
    }

    @GetMapping("{sourceId}")
    public AjaxResult selectDataById(@PathVariable("sourceId") Integer id) {
        return datasourceService.selectDataById(id);
    }

    @DeleteMapping("/datasource/{sourceId}")
    public AjaxResult deleteDataById(@PathVariable("sourceId") Integer id) {
        return datasourceService.deleteBySourceId(id);
    }
}
